-- Decompiled with the Synapse X Luau decompiler.

local SoundService = game:GetService("SoundService");
local ServerOHOH = _G.ServerOHOH;
local M = ServerOHOH.class.new(script, ServerOHOH.files.AudioManager());
local SoundsFolder = Instance.new("Folder", SoundService);
SoundsFolder.Name = "Sounds";
local GroupsFolder = Instance.new("Folder", SoundService);
GroupsFolder.Name = "Groups";
local ServerGlobleSoundsFolder = Instance.new("Folder", workspace);
ServerGlobleSoundsFolder.Name = "ServerGlobleSounds";
local AudioGroup_Cfg=ServerOHOH.config.AudioGroup
local Group = {};
function M.CreateGroup(self, id)
	if not id then
		return;
	end;
	if not Group[id] then
		local g = Instance.new("SoundGroup", GroupsFolder);
		g.Name = id;
		g.Volume=AudioGroup_Cfg[id]
		Group[id] = g;
	end;
	return Group[id];
end;
local Sounds = {};
function M.CreateSound(self, id, rid, volume, group,instanceList,property)
	local s = Instance.new("Sound", SoundsFolder);
	s.Name = id;
	s.SoundId = rid;
	s.Volume =  volume or 1;
	s.SoundGroup = group;
	Sounds[id] = s;
	s.Loaded:Connect(function()

	end);
	if instanceList then
		for _, v in pairs(instanceList) do
			Instance.new(v, s)
		end
	end
	
	if property then
		for k, v in pairs(property) do
			s[k]=v
		end
	end
end;

function M.PlayToInst(self, sid, parent, playbackSpeed, loopNum)
	return M.super.PlayToInst(self, Sounds[sid], parent, playbackSpeed, loopNum);
end;
function M.PlayGloble(self, sid, playbackSpeed, loopNum)
	return self:PlayToInst(sid, ServerGlobleSoundsFolder, playbackSpeed, loopNum);
end;
function M.SetGroupVolume(self, gid, volume)
	Group[gid].Volume = volume;
end;
function M.GetGroupVolume(self, gid)
	return Group[gid].Volume;
end;

for k, v in pairs(AudioGroup_Cfg) do
	M:CreateGroup(k)
end
for k, v in pairs(ServerOHOH.config.audio) do
	
	M:CreateSound(k, v.rid, v.volume, (M:CreateGroup(v.group)),v.instance,v.property);
end;
return M;
